﻿using System.Security.Claims;

namespace WXWorkSvc.Common.Extensions;

public static class ClaimExtensions
{
    
    public static string GetUserName(this ClaimsPrincipal user)
    {
        return ((ClaimsIdentity?)user.Identity)?.FindFirst(ClaimTypes.GivenName)?.Value ?? "";
    }
    public static string GetCorpName(this ClaimsPrincipal user)
    {
        return ((ClaimsIdentity?)user.Identity)?.FindFirst("CorpName")?.Value ?? "OpenPms";
    }
    public static string GetCorpId(this ClaimsPrincipal user)
    {
        return ((ClaimsIdentity?)user.Identity)?.FindFirst("CorpId")?.Value ?? "";
    }

    public static string GetExt(this ClaimsPrincipal user)
    {
        return ((ClaimsIdentity?)user.Identity)?.FindFirst("Ext")?.Value ?? "";
    }
    public static int GetExtId(this ClaimsPrincipal user)
    {
        return int.Parse(((ClaimsIdentity?)user.Identity)?.FindFirst("ExtId")?.Value ?? "0");
    }

}
